<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link href="skin/content-show.css" rel="stylesheet" />
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
</head>
<body ontouchstart>
<div id="main" class="loading" ></div>
</body>
<script type="text/javascript">
	zy_init();
	var url,bodyHtml,ContentHtml,Page,PageInt,News;	
	function Get(t){//点评或分享操作成功时候的提示
		uexWindow.toast("0","5",t,1000);
	}
	function Empty(){
		$$('main').innerHTML='';
	}
	function GetMain(t){
		$$('main').className="loading";
		url= app_api+'&a=show&id='+localStorage['news_id']+'&catid='+localStorage['news_catid'];
		bodyHtml=ContentHtml='';
		Page=0;
		PageInt=1;
		News={};
		uexXmlHttpMgr.open(t,'get',url,"8000");
		uexXmlHttpMgr.send(t);
	}
	window.uexOnload = function(type){
		if (!type) {
			uexWindow.setBounce("1");
			//uexWindow.evaluateScript('',0,'Id=0');			
			uexXmlHttpMgr.onData = function(opId, status, data){
				if(opId==-1){
					if(status==1){
						uexXmlHttpMgr.close(opId);
						data=JSON.parse(data);//把返回的字符转对象
						//	
						News=data['news'];
						if(News.length!=0){
							localStorage['news_title']=News['title'];
							localStorage['news_url']= encodeURI(News['url']);
							
							

							ContentHtml=News['content'].replace(/\r\n/g, '<br />');
							ContentHtml=ContentHtml.split('{page}');
							PageInt=ContentHtml.length;
							bodyHtml='<header style=" background-color:'+News['color']+'">'+
			    				 '<div class="title">'+News['title']+'</div>'+
			    				 '<div class="time">更新时间：'+News['uptime']+'　浏览量：'+News['hits']+'</div>'+
			    				 '</header>'+
			    				 '<section id="content"></section>';
							bodyHtml+='<div id="page"></div>';
							bodyHtml+='<footer><div id="comment"><p>最新评论</p></div></footer>';
							$$('main').innerHTML=bodyHtml;
							to_page();setPing(data['ping']);
							//uexWindow.evaluateScript('',0,'set()');
						}else{
							uexWindow.alert('','资讯不存在','关闭');					
							uexWindow.evaluateScript('',0,'goBack()');
						}
						//
					}else if(status==-1){
						uexXmlHttpMgr.close(opId);
						$$('main').className='errer';						
					}
				}else if(opId==0){					
					if(status==1){
						uexXmlHttpMgr.close(opId);
						data=JSON.parse(data);//把返回的字符转对象
						if(data.length>0){
							$$('comment').innerHTML='<p>最新评论</p>';
							setPing(data);
						}
					}else if(status==-1){
						uexXmlHttpMgr.close(opId);						
					}
				}
			}
			GetMain(-1);
		}
	}
	
	function to_page(t){
		$$('main').className='';
		var Html=pageHtml='';	
		if(t==0){
			for(i=0;i<ContentHtml.length;i++){
				Html+=ContentHtml[i];
			}
		}else{
			Page=t?Page+t:Page;
			Html=ContentHtml[Page];
			pageHtml='<div class="pageint">';
			if(Page>0){
				pageHtml+='<span ontouchstart="zy_touch(\'down\')" onclick="to_page(-1)">上一页</span>';
			}else{
				pageHtml+='<span class="no">上一页</span>';
			}		
			if(PageInt>1){
				pageHtml+='<span ontouchstart="zy_touch(\'down\')" onclick="to_page(0)">余下全文</span>';
			}else{
				pageHtml+='<span class="no">余下全文</span>';			
			}
			if((Page+1)>=PageInt){
				pageHtml+='<span class="no">下一页</span></div>';
			}else{
				pageHtml+='<span ontouchstart="zy_touch(\'down\')" onclick="to_page(1)">下一页</span></div>';
			}
			pageHtml+='<div class="pagetext">（'+(Page+1)+'/'+PageInt+'）</div>';
		}
		if(News['source']!=''&&(Page+1)==PageInt){
			Html+='<div id="source">来自：<span>'+News['source']+'</span><div>';
		}
		$$('content').innerHTML=Html;
		$$('page').innerHTML=pageHtml;
		document.getElementsByTagName('body')[0].scrollTop=0;
	}
	function setPing(Ping){
		if(Ping.length>0){
			var pLen=Ping.length>10?10:Ping.length;
			for(i=0;i<pLen;i++){
				var pTime =Ping[i]['addtime'];
				var d=new Date(pTime*1000);
				var Ul=document.createElement("ul");
				Ul.innerHTML='<span style="left:0;">'+Ping[i]['nick']+'</span><span style="right:0;">'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()+' '+d.getHours()+':'+d.getMinutes()+'</span><li>'+Ping[i]['content']+'</li>';
				$$('comment').appendChild(Ul);
			}
			if(Ping.length>9){
				var C=document.createElement("center");
				C.innerHTML='更多评论';
				C.className='more';
				C.ontouchstart=function(){zy_touch('down')};
				C.onclick=function(){jump_details('news_comment_list','news_comment_list.html')};
				$$('comment').appendChild(C);
			}
		}else{
			var C=document.createElement("center");
			C.innerHTML='暂无评论';
			$$('comment').appendChild(C);	
		}
		//document.getElementsByTagName('body')[0].scrollTop=document.getElementsByTagName('body')[0].scrollHeight;
	}
	function getMain(){
		uexXmlHttpMgr.open(0,'post','http://a.578.cn/news/ping.php?id='+localStorage['news_id'],"60000");
		uexXmlHttpMgr.send(0);
	}
	function jump_details(windowname,url){
		uexWindow.open(windowname, '0', url, '2', '', '', 0);
	}
	</script>
</html>